package cn.xshi.oauth.service.impl;
import java.util.List;
import java.util.Map;

import cn.xshi.oauth.dao.OauthFunctionCommonDao;
import cn.xshi.oauth.model.OauthFunctionCommon;
import cn.xshi.common.idgeneration.UUID;
import cn.xshi.oauth.service.OauthFunctionCommonService;
import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
/**
 * @Desc 授权中心公共功能
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class OauthFunctionCommonServiceImpl extends BaseService implements OauthFunctionCommonService {

	@Resource
	private OauthFunctionCommonDao oauthFunctionCommonDao;

	/**
	* 分页
	* @param condition 
	* @return
	*/
	public List<OauthFunctionCommon> getOauthFunctionCommonListByCondition(Map<String,Object> condition){
		try{
			return oauthFunctionCommonDao.getOauthFunctionCommonListByCondition(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 查询对象
	* @param id
	* @return
	*/
	public OauthFunctionCommon getOauthFunctionCommonById(String id){
		try{
			OauthFunctionCommon oauthFunctionCommon = oauthFunctionCommonDao.getOauthFunctionCommonById(id);
			return oauthFunctionCommon;
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 添加
	* @param oauthFunctionCommon 
	* @return
	*/
	public int addOauthFunctionCommon(OauthFunctionCommon oauthFunctionCommon){
		int i = 0;
		try {
			oauthFunctionCommon.setId(UUID.toUUID());
			oauthFunctionCommon.setCreateId(getCurrentAccountId());
			oauthFunctionCommon.setCreateTime(getDate());
			i = oauthFunctionCommonDao.addOauthFunctionCommon(oauthFunctionCommon);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改
	* @param oauthFunctionCommon 
	* @return
	*/
	public int updateOauthFunctionCommon(OauthFunctionCommon oauthFunctionCommon){
		int i = 0;
		try {
			oauthFunctionCommon.setUpdateId(getCurrentAccountId());
			oauthFunctionCommon.setUpdateTime(getDate());
			i = oauthFunctionCommonDao.updateOauthFunctionCommon(oauthFunctionCommon);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改（根据动态条件）
	* @param oauthFunctionCommon 
	* @return
	*/
	public int updateOauthFunctionCommonBySelective(OauthFunctionCommon oauthFunctionCommon){
		int i = 0;
		try {
			oauthFunctionCommon.setUpdateId(getCurrentAccountId());
			oauthFunctionCommon.setUpdateTime(getDate());
			i = oauthFunctionCommonDao.updateOauthFunctionCommonBySelective(oauthFunctionCommon);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 删除
	* @param condition 
	* @return
	*/
	public int delOauthFunctionCommon(Map<String,Object> condition){
		int i = 0;
		try {
			i = oauthFunctionCommonDao.delOauthFunctionCommon(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 批量修改
	* @param oauthFunctionCommonList 
	* @return
	*/
	public int updateBatchOauthFunctionCommon(List<OauthFunctionCommon> oauthFunctionCommonList){
		int i = 0;
		try {
			i = oauthFunctionCommonDao.updateBatchOauthFunctionCommon(oauthFunctionCommonList);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 批量修改（根据动态条件）
	* @param oauthFunctionCommonList 
	* @return
	*/
	public int updateBatchOauthFunctionCommonBySelective(List<OauthFunctionCommon> oauthFunctionCommonList){
		int i = 0;
		try {
			i = oauthFunctionCommonDao.updateBatchOauthFunctionCommonBySelective(oauthFunctionCommonList);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}
}
